package com.training.permission.action.chengshu;

import java.util.List;

import com.opensymphony.xwork2.ActionSupport;
import com.training.permission.service.impl.chengshu.PermissionServiceImpl;
import com.training.pojo.chengshu.IsRolePermission;
import com.training.pojo.chengshu.UFunction;
import com.training.pojo.chengshu.URole;

@SuppressWarnings("serial")
public class UpdatePerRoleAction extends ActionSupport{
	private PermissionServiceImpl permissionService;
	private String id;
	private String name;
	private URole role;
	private List<UFunction> listo,allList;
	private List<IsRolePermission> list;
	private String[] selectID;
	
	public String[] getSelectID() {
		return selectID;
	}
	public void setSelectID(String[] selectID) {
		this.selectID = selectID;
	}
	public List<UFunction> getListo() {
		return listo;
	}
	public void setListo(List<UFunction> listo) {
		this.listo = listo;
	}
	public List<UFunction> getAllList() {
		return allList;
	}
	public void setAllList(List<UFunction> allList) {
		this.allList = allList;
	}
	public List<IsRolePermission> getList() {
		return list;
	}
	public void setList(List<IsRolePermission> list) {
		this.list = list;
	}
	public URole getRole() {
		return role;
	}
	public void setRole(URole role) {
		this.role = role;
	}
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public void setPermissionService(PermissionServiceImpl permissionService) {
		this.permissionService = permissionService;
	}
	public String execute(){
		if(permissionService.updatePermission(selectID, id)){
			this.addFieldError("infor", "修改成功！");
		}else{
			this.addFieldError("infor", "修改失败！");
		}
		showuf();
		return SUCCESS;
	}
	public String showuf(){
		role = new URole();
		role.setRoleid(Integer.parseInt(id));
		role.setRolename(name);
		listo = permissionService.listuf(role);
		allList = permissionService.listAllUF();
		//System.out.println(allList.size()+"测试长度");
		//list = permissionService.listRolePer(permissionService.listuf(role), permissionService.listAllUF());
		return SUCCESS;
	} 
}
